package com.dianping.cat.home.user.transform;

import com.dianping.cat.home.user.entity.User;
import com.dianping.cat.home.user.entity.UserConfig;
import org.xml.sax.Attributes;




public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public User buildUser(Attributes attributes) {
/* 15 */     String id = attributes.getValue("id");
/* 16 */     String role = attributes.getValue("role");
/* 17 */     User user = new User(id);

/* 19 */     if (role != null) {
/* 20 */       user.setRole(((Integer)convert(Integer.class, role, Integer.valueOf(0))).intValue());
    }

/* 23 */     return user;
  }



/* 28 */   public UserConfig buildUserConfig(Attributes attributes) { return new UserConfig(); }





  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 35 */     if (value == null || value.length() == 0) {
/* 36 */       return defaultValue;
    }

/* 39 */     if (type == Boolean.class || type == boolean.class)
/* 40 */       return (T)Boolean.valueOf(value); 
/* 41 */     if (type == Integer.class || type == int.class)
/* 42 */       return (T)Integer.valueOf(value); 
/* 43 */     if (type == Long.class || type == long.class)
/* 44 */       return (T)Long.valueOf(value); 
/* 45 */     if (type == Short.class || type == short.class)
/* 46 */       return (T)Short.valueOf(value); 
/* 47 */     if (type == Float.class || type == float.class)
/* 48 */       return (T)Float.valueOf(value); 
/* 49 */     if (type == Double.class || type == double.class)
/* 50 */       return (T)Double.valueOf(value); 
/* 51 */     if (type == Byte.class || type == byte.class)
/* 52 */       return (T)Byte.valueOf(value); 
/* 53 */     if (type == Character.class || type == char.class) {
/* 54 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 56 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/classes/!/com/dianping/cat/home/user/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */